package com.lfy.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@AllArgsConstructor
@Getter
public enum JobStatusEnum {
    NONE("NONE", "不存在"),
    STATE_NORMAL("NORMAL", "执行中"),
    STATE_PAUSED("PAUSED", "暂停中"),
    STATE_COMPLETE("COMPLETE","完成"),
    STATE_ERROR("ERROR", "错误"),
    STATE_ONCE("ONCE", "单次任务"),
    STATE_BLOCKED("BLOCKED", "阻塞"),

    ;
    private static Map<String,String > map ;
    static {
        map = Stream.of(JobStatusEnum.values()).collect(Collectors.toMap(JobStatusEnum::getKey, JobStatusEnum::getValue));
    }
    final String key;
    final String value;
    public static String getValueByKey(String key) {

        if (!map.containsKey(key)) {
            return null;
        }
        return map.get(key);
    }

}
